package com.bootdo.program.wallpaper.job;

import com.bootdo.oa.domain.Response;
import com.bootdo.program.wallpaper.service.BzTalentService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author guoyunfei on 2022/1/21 10:42
 * @className BzTalentJob
 * @description TODO 创作者入住申请job
 * @Version 1.0
 */

@Component
public class BzTalentJob implements Job {

    @Autowired
    SimpMessagingTemplate template;

    @Autowired
    private BzTalentService bzTalentService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        Map<String,Object> map = new HashMap<>();
        map.put("status",1);
        int count = bzTalentService.count(map);
        if(count > 0){
            template.convertAndSend("/topic/talentJob", new Response("您有"+count+"位创作者申请待审核,请及时处理" ));
        }
    }
}
